import { selectPage } from '@/services/cust/integralDetails';
import { ProTable } from '@ant-design/pro-components';
import { useParams } from '@umijs/max';
import { useRef } from 'react';
import { columns } from './columns';

export default () => {
  const ref = useRef();
  const { id } = useParams();
  return (
    <div>
      <ProTable
        headerTitle="积分明细列表"
        actionRef={ref}
        options={false}
        search={{
          labelWidth: 'auto',
        }}
        request={async (params = {}) => {
          const { current, pageSize, ...formData } = params;
          let body = {
            pageNum: current,
            pageSize,
            userId: Number(id),
            ...formData,
          };
          const { code, data, total } = await selectPage(body);
          if (code && code === 200) {
            return {
              data: data || [],
              total: total,
              success: true,
            };
          }
        }}
        toolBarRender={() => []}
        pagination={{
          showSizeChanger: true,
        }}
        cardProps={{
          size: 'small',
          style: {
            padding: 0,
          },
        }}
        cardBordered={true}
        columns={columns()}
        rowKey="id"
      />
    </div>
  );
};
